package cn.ronghuanet.base.util;

import lombok.Data;

@Data
public class AjaxResult {
    private Boolean success;
    private Object data;
    private String msg;

    public static AjaxResult success(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success = true;
        ajaxResult.msg = "操作成功";
        return ajaxResult;
    }

    public static AjaxResult success(Object data){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success = true;
        ajaxResult.data = data;
        ajaxResult.msg = "操作成功";
        return ajaxResult;
    }
    public static AjaxResult success(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success = true;
        ajaxResult.msg = msg;
        return ajaxResult;
    }

    public static AjaxResult error(String msg){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success = false;
        ajaxResult.msg = msg;
        return ajaxResult;
    }

    public static AjaxResult error(){
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.success = false;
        ajaxResult.msg = "网络异常请联系管理员";
        return ajaxResult;
    }
}
